package com.dashanchessgame.chess;

import com.dashanchessgame.tools.ImageTool;

import java.awt.*;

/**
 * 士
 *
 * @author 37460
 */
public class ChessShi implements Chess {
    @Override
    public boolean chessCheck(int[][] map, int nowLineNumber, int nowColumnNumber, int toLineNumber, int toColumnNumber, boolean isChessColor) {
        //获取相差的行数和列数
        int istoLineNumber = Math.abs(nowLineNumber - toLineNumber);
        int istoColumnNumber = Math.abs(nowColumnNumber - toColumnNumber);

        //判断方向是不是斜着走的，相差的行和列都必须是1才可以,不能超出士的行进范围田字格
        if (istoLineNumber == 1 && istoColumnNumber == 1 && ((toLineNumber <= 10 && toLineNumber >= 8) || (toColumnNumber <= 5 && toColumnNumber >= 3))) {
            return true;
        } else {
            return false;
        }

    }

    @Override
    public int getType() {
        return 'S';
    }


    @Override
    public Image getImage(boolean isChessColor) {
        return ImageTool.loadImage(isChessColor ? "黑士.gif" : "红士.gif");
    }
}
